package model;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public class Spring extends Platform implements Item
{
	
	private boolean extended = false;
	
	public Spring(double cX, double cY) throws SlickException
	{
		super(cX, cY);
		image = new Image("data/feder.png");
		width = 0.04;
		height = 0.04;
	}
	
	public Type getType()
	{
		return Type.FEDER;
	}
	
	@Override
	public void act()
	{
		if (super.misterJumpsOn())
		{
			Wrapper model = Wrapper.getInstance();
			model.setMisterYGeschwindigkeit(0.03); // TODO anstaendigen Wert finden
			model.setMisterY(this.getY() + this.getHeight() - model.getMisterYGeschwindigkeit());
			extended = true;
			height = 0.08;
		}
		
	}
	
	public Image getImage()
	{
		Image img = super.getImage();
		if (!extended)
		{
			return img.getSubImage(0, 0, img.getWidth(), img.getHeight()/3);
		}
		else 
		{
			return img.getSubImage(0, img.getHeight()/3, img.getWidth(), img.getHeight()*2/3);
		}
		
	}
	
	
	
}
